#ifndef VXZOOMCONTROLLER_H
#define VXZOOMCONTROLLER_H

#include <QtGui>

struct VxViewPoint{
	QPointF scenePoint;
	QPoint viewPoint;
	qreal scale;
};


class VxZoomController : public QObject
{

	Q_OBJECT

	Q_PROPERTY(qreal scale READ getScale WRITE _setScale)

public:
	VxZoomController(QGraphicsView * view);
	~VxZoomController();
	
	qreal getScale();
	void scaleToView(qreal scale, QPoint * viewPoint=NULL, bool animated=true);
	void scaleToScene(qreal scale, QPointF * scenePoint, bool animated=true);

	VxViewPoint * getViewPoint();
	void setViewPoint(VxViewPoint * vpoint, bool animated=true);
	void scaleTo(qreal scale);
	void centerOn(QPointF vp);


private:
	QGraphicsView * _view;
	QPropertyAnimation * _animationScale;

	QPoint _viewPoint;
	QPointF _scenePoint;
	VxViewPoint * _backScale;

	void _setScale(qreal scale);


signals:
	void scaleShanged(int scale);
	void scaleAnimated(qreal scale);

private slots:
	void _animationScaleFinished();

public slots:
	void zoomFitToAll(bool animated=false);
	void zoomToBack(bool animated=false);
	void zoomByWheel(int delta);
	void cancelAnimation();

};



#endif // VXZOOMCONTROLLER_H
